package cn.iocoder.yudao.module.pay.order.mq;

import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.module.api.pay.order.message.PayCloseMessage;
import cn.iocoder.yudao.module.api.pay.order.message.PayExpireMessage;
import cn.iocoder.yudao.module.api.pay.order.message.PaySuccessMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 付款单据 事件生产者
 *
 * @author 山野羡民（1032694760@qq.com）
 */
@Slf4j
@Component
public class PayOrderProducer {

    public void sendPaySuccessMessage(String tradeNo, String payNo) {
        log.info("[sendPaySuccessMessage][tradeNo({}) payNo({})]", tradeNo, payNo);
        SpringUtil.getApplicationContext().publishEvent(new PaySuccessMessage(tradeNo, payNo));
    }

    public void sendPayCloseMessage(String tradeNo, String payNo) {
        log.info("[sendPayCloseMessage][tradeNo({}) payNo({})]", tradeNo, payNo);
        SpringUtil.getApplicationContext().publishEvent(new PayCloseMessage(tradeNo, payNo));
    }


    public void sendPayExpireMessage(String tradeNo, String payNo) {
        log.info("[sendPayExpireMessage][tradeNo({}) payNo({})]", tradeNo, payNo);
        SpringUtil.getApplicationContext().publishEvent(new PayExpireMessage(tradeNo, payNo));
    }

}
